home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209b.zip / octave-2.09 / doc / octave.i10 (.txt) < prev    next >
GNU Info File  |  1997-08-20  |  43KB  |  814 lines

  1. This is Info file octave, produced by Makeinfo-1.64 from the input file
  2. octave.tex.
  3. START-INFO-DIR-ENTRY
  4. * Octave: (octave).     Interactive language for numerical computations.
  5. END-INFO-DIR-ENTRY
  6.    Copyright (C) 1996, 1997 John W. Eaton.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided that
  12. the entire resulting derived work is distributed under the terms of a
  13. permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions.
  17. File: octave,  Node: Sending Patches,  Next: Service,  Prev: Bug Reporting,  Up: Trouble
  18. Sending Patches for Octave
  19. ==========================
  20.    If you would like to write bug fixes or improvements for Octave,
  21. that is very helpful.  When you send your changes, please follow these
  22. guidelines to avoid causing extra work for us in studying the patches.
  23.    If you don't follow these guidelines, your information might still be
  24. useful, but using it will take extra work.  Maintaining Octave is a lot
  25. of work in the best of circumstances, and we can't keep up unless you do
  26. your best to help.
  27.    * Send an explanation with your changes of what problem they fix or
  28.      what improvement they bring about.  For a bug fix, just include a
  29.      copy of the bug report, and explain why the change fixes the bug.
  30.    * Always include a proper bug report for the problem you think you
  31.      have fixed.  We need to convince ourselves that the change is
  32.      right before installing it.  Even if it is right, we might have
  33.      trouble judging it if we don't have a way to reproduce the problem.
  34.    * Include all the comments that are appropriate to help people
  35.      reading the source in the future understand why this change was
  36.      needed.
  37.    * Don't mix together changes made for different reasons.  Send them
  38.      *individually*.
  39.      If you make two changes for separate reasons, then we might not
  40.      want to install them both.  We might want to install just one.
  41.    * Use `diff -c' to make your diffs.  Diffs without context are hard
  42.      for us to install reliably.  More than that, they make it hard for
  43.      us to study the diffs to decide whether we want to install them.
  44.      Unidiff format is better than contextless diffs, but not as easy
  45.      to read as `-c' format.
  46.      If you have GNU diff, use `diff -cp', which shows the name of the
  47.      function that each change occurs in.
  48.    * Write the change log entries for your changes.
  49.      Read the `ChangeLog' file to see what sorts of information to put
  50.      in, and to learn the style that we use.  The purpose of the change
  51.      log is to show people where to find what was changed.  So you need
  52.      to be specific about what functions you changed; in large
  53.      functions, it's often helpful to indicate where within the
  54.      function the change was made.
  55.      On the other hand, once you have shown people where to find the
  56.      change, you need not explain its purpose. Thus, if you add a new
  57.      function, all you need to say about it is that it is new.  If you
  58.      feel that the purpose needs explaining, it probably does--but the
  59.      explanation will be much more useful if you put it in comments in
  60.      the code.
  61.      If you would like your name to appear in the header line for who
  62.      made the change, send us the header line.
  63. File: octave,  Node: Service,  Prev: Sending Patches,  Up: Trouble
  64. How To Get Help with Octave
  65. ===========================
  66.    The mailing list (help-octave@bevo.che.wisc.edu) exists for the
  67. discussion of matters related to using and installing Octave.  If would
  68. like to join the discussion, please send a short note to
  69. (help-octave*-request*@bevo.che.wisc.edu).
  70.    *Please do not* send requests to be added or removed from the the
  71. mailing list, or other administrative trivia to the list itself.
  72.    If you think you have found a bug in the installation procedure,
  73. however, you should send a complete bug report for the problem to
  74. (bug-octave@bevo.che.wisc.edu).  *Note Bug Reporting:: for information
  75. that will help you to submit a useful report.
  76. File: octave,  Node: Installation,  Next: Emacs,  Prev: Trouble,  Up: Top
  77. Installing Octave
  78. *****************
  79.    Here is the procedure for installing Octave from scratch on a Unix
  80. system.  For instructions on how to install the binary distributions of
  81. Octave, see *Note Binary Distributions::.
  82.    * Run the shell script `configure'.  This will determine the features
  83.      your system has (or doesn't have) and create a file named
  84.      `Makefile' from each of the files named `Makefile.in'.
  85.      Here is a summary of the configure options that are most
  86.      frequently used when building Octave:
  87.     `--prefix=PREFIX'
  88.           Install Octave in subdirectories below PREFIX.  The default
  89.           value of PREFIX is `/usr/local'.
  90.     `--srcdir=DIR'
  91.           Look for Octave sources in the directory DIR.
  92.     `--with-f2c'
  93.           Use `f2c' even if a Fortran compiler is available.
  94.     `--with-g77'
  95.           Use `g77' to compile Fortran code.
  96.     `--enable-shared'
  97.           Create shared libraries.  If you are planning to use
  98.           `--enable-lite-kernelel' or the dynamic loading features, you
  99.           will probably want to use this option.  It will make your
  100.           `.oct' files much smaller and on some systems it may be
  101.           necessary to build shared libraries in order to use
  102.           dynamically linked functions.
  103.           You may also want to build a shared version of `libg++', if
  104.           your system doesn't already have one.  Note that a patch is
  105.           needed to build shared versions of version 2.7.2 of `libg++'
  106.           and `libstdc++' on the HP-PA architecture.  You can find the
  107.           patch at
  108.           (ftp://ftp.cygnus.com/pub/g++/libg++-2.7.2-hppa-gcc-fix).
  109.     `--enable-dl'
  110.           Use `dlopen' and friends to make Octave capable of dynamically
  111.           linking externally compiled functions.  This only works on
  112.           systems that actually have these functions.  If you plan on
  113.           using this feature, you should probably also use
  114.           `--enable-shared' to reduce the size of your `.oct' files.
  115.     `--enable-shl'
  116.           Use `shl_load' and friends to make Octave capable of
  117.           dynamically linking externally compiled functions.  This only
  118.           works on systems that actually have these functions (only
  119.           HP-UX systems).  If you plan on using this feature, you
  120.           should probably also use `--enable-shared' to reduce the size
  121.           of your `.oct' files.
  122.     `--enable-lite-kernel'
  123.           Compile smaller kernel.  This currently requires the dynamic
  124.           linking functions `dlopen' or `shl_load' and friends so that
  125.           Octave can load functions at run time that are not loaded at
  126.           compile time.
  127.     `--help'
  128.           Print a summary of the options recognized by the configure
  129.           script.
  130.      See the file `INSTALL' for more information about the command line
  131.      options used by configure.  That file also contains instructions
  132.      for compiling in a directory other than where the source is
  133.      located.
  134.    * Run make.
  135.      You will need a recent version of GNU Make.  Modifying Octave's
  136.      makefiles to work with other make programs is probably not worth
  137.      your time.  We recommend you get and compile GNU Make instead.
  138.      For plotting, you will need to have gnuplot installed on your
  139.      system.  Gnuplot is a command-driven interactive function plotting
  140.      program.  Gnuplot is copyrighted, but freely distributable.  The
  141.      `gnu' in gnuplot is a coincidence--it is not related to the GNU
  142.      project or the FSF in any but the most peripheral sense.
  143.      For version 2.0.5, you must have the GNU C++ compiler (`gcc')
  144.      version 2.7.2 or later to compile Octave.  You will also need
  145.      version 2.7.1 or 2.7.2 of the GNU C++ class library (`libg++').
  146.      If you plan to modify the parser you will also need GNU `bison'
  147.      and `flex'.  If you modify the documentation, you will need GNU
  148.      Texinfo, along with the patch for the `makeinfo' program that is
  149.      distributed with Octave.
  150.      GNU Make, `gcc', and `libg++', `gnuplot', `bison', `flex', and
  151.      Texinfo are all available from many anonymous ftp archives.  The
  152.      primary site is (prep.ai.mit.edu), but it is often very busy.  A
  153.      list of sites that mirror the software on `prep' is available by
  154.      anonymous ftp from (ftp://prep.ai.mit.edu/pub/gnu/GNUinfo/FTP), or
  155.      by fingering (fsf@prep.ai.mit.edu).
  156.      If you don't have a Fortran compiler, or if your Fortran compiler
  157.      doesn't work like the traditional Unix f77, you will need to have
  158.      the Fortran to C translator `f2c'.  You can get `f2c' from any
  159.      number of anonymous ftp archives.  The most recent version of `f2c'
  160.      is always available from (netlib.att.com).
  161.      On an otherwise idle Pentium 133 running Linux, it will take
  162.      somewhere between 1-1/2 to 3 hours to compile everything,
  163.      depending on whether you are building shared libraries.  You will
  164.      need about 100 megabytes of disk storage to work with
  165.      (considerably less if you don't compile with debugging symbols).
  166.      To do that, use the command
  167.           make CFLAGS=-O CXXFLAGS=-O LDFLAGS=
  168.      instead of just `make'.
  169.    * If you encounter errors while compiling Octave, first check the
  170.      list of known problems below to see if there is a workaround or
  171.      solution for your problem.  If not, see *Note Trouble::, for
  172.      information about how to report bugs.
  173.    * Once you have successfully compiled Octave, run `make install'.
  174.      This will install a copy of octave, its libraries, and its
  175.      documentation in the destination directory.  As distributed,
  176.      Octave is installed in the following directories.  In the table
  177.      below, PREFIX defaults to `/usr/local', VERSION stands for the
  178.      current version number of the interpreter, and ARCH is the type of
  179.      computer on which Octave is installed (for example,
  180.      `i586-unknown-gnu').
  181.     `PREFIX/bin'
  182.           Octave and other binaries that people will want to run
  183.           directly.
  184.     `PREFIX/lib'
  185.           Libraries like libcruft.a and liboctave.a.
  186.     `PREFIX/share'
  187.           Architecture-independent data files.
  188.     `PREFIX/include/octave'
  189.           Include files distributed with Octave.
  190.     `PREFIX/man/man1'
  191.           Unix-style man pages describing Octave.
  192.     `PREFIX/info'
  193.           Info files describing Octave.
  194.     `PREFIX/share/octave/VERSION/m'
  195.           Function files distributed with Octave.  This includes the
  196.           Octave version, so that multiple versions of Octave may be
  197.           installed at the same time.
  198.     `PREFIX/lib/octave/VERSION/exec/ARCH'
  199.           Executables to be run by Octave rather than the user.
  200.     `PREFIX/lib/octave/VERSION/oct/ARCH'
  201.           Object files that will be dynamically loaded.
  202.     `PREFIX/share/octave/VERSION/imagelib'
  203.           Image files that are distributed with Octave.
  204. * Menu:
  205. * Notes::
  206. * Installation Problems::
  207. * Binary Distributions::
  208. File: octave,  Node: Notes,  Next: Installation Problems,  Prev: Installation,  Up: Installation
  209. Notes
  210. =====
  211.    * You must use the version of GNU Info distributed with Octave,
  212.      because it includes some changes to allow Octave to search the
  213.      indices of the info files.  If you would like, you should be able
  214.      to replace other copies of the Info browser that you have with the
  215.      one distributed with Octave.  Patches relative to a recent release
  216.      of the GNU Info browser are included in the file `INFO.PATCH' in
  217.      the Octave source distribution.  This modification has been
  218.      submitted to the GNU Info maintainer, and should appear in some
  219.      future release.  Once that happens, the GNU Info browser will no
  220.      longer be distributed with Octave.
  221. File: octave,  Node: Installation Problems,  Next: Binary Distributions,  Prev: Notes,  Up: Installation
  222. Installation Problems
  223. =====================
  224.    This section contains a list of problems (and some apparent problems
  225. that don't really mean anything is wrong) that may show up during
  226. installation of Octave.
  227.    * On some SCO systems, `info' fails to compile if `HAVE_TERMIOS_H'
  228.      is defined int `config.h'.  Simply removing the definition from
  229.      `info/config.h' should allow it to compile.
  230.    * If `configure' finds `dlopen', `dlsym', `dlclose', and `dlerror',
  231.      but not the header file `dlfcn.h', you need to find the source for
  232.      the header file and install it in the directory `usr/include'.
  233.      This is reportedly a problem with Slackware 3.1.  For Linux/GNU
  234.      systems, the source for `dlfcn.h' is in the `ldso' package.
  235.    * Building `.oct' files doesn't work.
  236.      You should probably have a shared version of `libg++'.  A patch is
  237.      needed to build shared versions of version 2.7.2 of `libg++' and
  238.      `libstdc++' on the HP-PA architecture.  You can find the patch at
  239.      (ftp://ftp.cygnus.com/pub/g++/libg++-2.7.2-hppa-gcc-fix).
  240.    * If you encounter errors like
  241.           passing `void (*)()' as argument 2 of
  242.             `octave_set_signal_handler(int, void (*)(int))'
  243.      or
  244.           warning: ANSI C++ prohibits conversion from `(int)' to `(...)'
  245.      while compiling `sighandlers.cc', you may need to edit some files
  246.      in the `gcc' include subdirectory to add proper prototypes for
  247.      functions there.  For example, Ultrix 4.2 needs proper
  248.      declarations for the `signal' function and the `SIG_IGN' macro in
  249.      the file `signal.h'.
  250.      On some systems the `SIG_IGN' macro is defined to be something like
  251.      this:
  252.           #define  SIG_IGN  (void (*)())1
  253.      when it should really be something like:
  254.           #define  SIG_IGN  (void (*)(int))1
  255.      to match the prototype declaration for the `signal' function.  This
  256.      change should also be made for the `SIG_DFL' and `SIG_ERR'
  257.      symbols. It may be necessary to change the definitions in
  258.      `sys/signal.h' as well.
  259.      The `gcc' `fixincludes' and `fixproto' scripts should probably fix
  260.      these problems when `gcc' installs its modified set of header
  261.      files, but I don't think that's been done yet.
  262.      *You should not change the files in `/usr/include'*.  You can find
  263.      the `gcc' include directory tree by running the command
  264.           gcc -print-libgcc-file-name
  265.      The directory of `gcc' include files normally begins in the same
  266.      directory that contains the file `libgcc.a'.
  267.    * There is a bug with the `makeinfo' program that is distributed with
  268.      Texinfo (through version 3.9) that causes the indices in Octave's
  269.      on-line manual to be generated incorrectly.  If you need to
  270.      recreate the on-line documentation, you should get the `makeinfo'
  271.      program that is distributed with texinfo-3.9 and apply the patch
  272.      for `makeinfo' that is distributed with Octave.  See the file
  273.      `MAKEINFO.PATCH' for more details.
  274.    * Some of the Fortran subroutines may fail to compile with older
  275.      versions of the Sun Fortran compiler.  If you get errors like
  276.           zgemm.f:
  277.                   zgemm:
  278.           warning: unexpected parent of complex expression subtree
  279.           zgemm.f, line 245: warning: unexpected parent of complex
  280.             expression subtree
  281.           warning: unexpected parent of complex expression subtree
  282.           zgemm.f, line 304: warning: unexpected parent of complex
  283.             expression subtree
  284.           warning: unexpected parent of complex expression subtree
  285.           zgemm.f, line 327: warning: unexpected parent of complex
  286.             expression subtree
  287.           pcc_binval: missing IR_CONV in complex op
  288.           make[2]: *** [zgemm.o] Error 1
  289.      when compiling the Fortran subroutines in the `libcruft'
  290.      subdirectory, you should either upgrade your compiler or try
  291.      compiling with optimization turned off.
  292.    * On NeXT systems, if you get errors like this:
  293.           /usr/tmp/cc007458.s:unknown:Undefined local symbol LBB7656
  294.           /usr/tmp/cc007458.s:unknown:Undefined local symbol LBE7656
  295.      when compiling `Array.cc' and `Matrix.cc', try recompiling these
  296.      files without `-g'.
  297.    * Some people have reported that calls to shell_cmd and the pager do
  298.      not work on SunOS systems.  This is apparently due to having
  299.      `G_HAVE_SYS_WAIT' defined to be 0 instead of 1 when compiling
  300.      `libg++'.
  301.    * On NeXT systems, linking to `libsys_s.a' may fail to resolve the
  302.      following functions
  303.           _tcgetattr
  304.           _tcsetattr
  305.           _tcflow
  306.      which are part of `libposix.a'.  Unfortunately, linking Octave with
  307.      `-posix' results in the following undefined symbols.
  308.           .destructors_used
  309.           .constructors_used
  310.           _objc_msgSend
  311.           _NXGetDefaultValue
  312.           _NXRegisterDefaults
  313.           .objc_class_name_NXStringTable
  314.           .objc_class_name_NXBundle
  315.      One kluge around this problem is to extract `termios.o' from
  316.      `libposix.a', put it in Octave's `src' directory, and add it to
  317.      the list of files to link together in the makefile.  Suggestions
  318.      for better ways to solve this problem are welcome!
  319.    * If Octave crashes immediately with a floating point exception, it
  320.      is likely that it is failing to initialize the IEEE floating point
  321.      values for infinity and NaN.
  322.      If your system actually does support IEEE arithmetic, you should
  323.      be able to fix this problem by modifying the function
  324.      `octave_ieee_init' in the file `lo-ieee.cc' to correctly
  325.      initialize Octave's internal infinity and NaN variables.
  326.      If your system does not support IEEE arithmetic but Octave's
  327.      configure script incorrectly determined that it does, you can work
  328.      around the problem by editing the file `config.h' to not define
  329.      `HAVE_ISINF', `HAVE_FINITE', and `HAVE_ISNAN'.
  330.      In any case, please report this as a bug since it might be
  331.      possible to modify Octave's configuration script to automatically
  332.      determine the proper thing to do.
  333. File: octave,  Node: Binary Distributions,  Prev: Installation Problems,  Up: Installation
  334. Binary Distributions
  335. ====================
  336.    Although Octave is not very difficult to build from its sources, it
  337. is a relatively large program that does require a significant amount of
  338. time and disk space to compile and install.  Because of this, many
  339. people want to be able to obtain binary distributions so they can start
  340. using Octave immediately, without having to bother with the details of
  341. compiling it first.  This is understandable, so I try to maintain a
  342. current collection of binary distributions at
  343. (ftp://ftp.che.wisc.edu/pub/octave/BINARIES).
  344.    Please understand, however, that there is only a limited amount of
  345. time available to devote to making binaries, so binaries may not be
  346. immediately available for some platforms.  (Please contact
  347. (bug-octave@bevo.che.wisc.edu) if you are interested in helping make a
  348. binary distribution available for your system.)
  349.    Also, binary distributions are limited to static binaries that do not
  350. support dynamic linking.  For earlier versions of Octave, I tried
  351. distributing dynamically linked binaries but that proved to be too much
  352. trouble to support.  If you want to have a copy of Octave that includes
  353. all the features described in this manual, you will have to build it
  354. from the sources yourself, or find someone else who is willing to do it
  355. for you.
  356. * Menu:
  357. * Installing Octave from a Binary Distribution::
  358. * Creating a Binary Distribution::
  359. File: octave,  Node: Installing Octave from a Binary Distribution,  Next: Creating a Binary Distribution,  Prev: Binary Distributions,  Up: Binary Distributions
  360. Installing Octave from a Binary Distribution
  361. --------------------------------------------
  362.    To install Octave from a binary distribution, execute the command
  363.      sh ./install-octave
  364. in the top level directory of the distribution.
  365.    Binary distributions are normally compiled assuming that Octave will
  366. be installed in the following subdirectories of `/usr/local'.
  367. `bin'
  368.      Octave and other binaries that people will want to run directly.
  369. `lib'
  370.      Shared libraries that Octave needs in order to run.  These files
  371.      are not included if you are installing a statically linked version
  372.      of Octave.
  373. `man/man1'
  374.      Unix-style man pages describing Octave.
  375. `info'
  376.      Info files describing Octave.
  377. `share/octave/VERSION/m'
  378.      Function files distributed with Octave.  This includes the Octave
  379.      version, so that multiple versions of Octave may be installed at
  380.      the same time.
  381. `libexec/octave/VERSION/exec/ARCH'
  382.      Executables to be run by Octave rather than the user.
  383. `libexec/octave/VERSION/oct/ARCH'
  384.      Object files that will be dynamically loaded.
  385. `share/octave/VERSION/imagelib'
  386.      Image files that are distributed with Octave.
  387. where VERSION stands for the current version number of the interpreter,
  388. and ARCH is the type of computer on which Octave is installed (for
  389. example, `i486-OS/2').
  390.    If these directories don't exist, the script `install-octave' will
  391. create them for you.  The installation script also creates the following
  392. subdirectories of `/usr/local' that are intended for locally installed
  393. functions:
  394. `share/octave/site/m'
  395.      Locally installed M-files.
  396. `libexec/octave/site/exec/ARCH'
  397.      Locally installed binaries intended to be run by Octave rather
  398.      than by the user.
  399. `libexec/octave/site/octave/ARCH'
  400.      Local object files that will be dynamically linked.
  401.    If it is not possible for you to install Octave in `/usr/local', or
  402. if you would prefer to install it in a different directory, you can
  403. specify the name of the top level directory as an argument to the
  404. `install-octave' script.  For example:
  405.      sh ./install-octave /some/other/directory
  406. will install Octave in subdirectories of the directory
  407. `/some/other/directory'.
  408. File: octave,  Node: Creating a Binary Distribution,  Prev: Installing Octave from a Binary Distribution,  Up: Binary Distributions
  409. Creating a Binary Distribution
  410. ------------------------------
  411.    Here is how to build a binary distribution for others to use.  If you
  412. want to make a binary distribution for your system available along with
  413. the Octave sources and binaries on (ftp.che.wisc.edu), please follow
  414. this procedure.  For directions explaining how to make the binary
  415. available on the ftp site, please contact
  416. (bug-octave@bevo.che.wisc.edu).
  417.    * Unpack the source distribution:
  418.           gunzip -c octave-2.0.5.tar.gz | tar xf -
  419.    * Change your current directory to the top-level directory of the
  420.      source distribution:
  421.           cd octave-2.0.5
  422.    * Make the binary distribution:
  423.           make binary-dist
  424.      This will create a compressed tar file ready for distribution.  It
  425.      will contain statically linked binaries and have a name like
  426.      `octave-2.0.5-i486-OS/2.tar.gz'
  427. File: octave,  Node: Emacs,  Next: Grammar,  Prev: Installation,  Up: Top
  428. Using Emacs With Octave
  429. ***********************
  430.    The development of Octave code can greatly be facilitated using Emacs
  431. with Octave mode, a major mode for editing Octave files which can e.g.
  432. automatically indent the code, do some of the typing (with Abbrev mode)
  433. and show keywords, comments, strings, etc. in different faces (with
  434. Font-lock mode on devices that support it).
  435.    It is also possible to run Octave from within Emacs, either by
  436. directly entering commands at the prompt in a buffer in Inferior Octave
  437. mode, or by interacting with Octave from within a file with Octave
  438. code.  This is useful in particular for debugging Octave code.
  439.    Finally, you can convince Octave to use the Emacs info reader for
  440. `help -i'.
  441.    All functionality is provided by the Emacs Lisp package `octave'.
  442. This chapter describes how to set up and use this package.
  443.    Please contact (Kurt.Hornik@ci.tuwien.ac.at) if you have any
  444. questions or suggestions on using Emacs with Octave.
  445. * Menu:
  446. * Installing the Emacs Octave Package::
  447. * Using Octave Mode::
  448. * Running Octave From Within Emacs::
  449. * Using the Emacs Info Reader for Octave::
  450. File: octave,  Node: Installing the Emacs Octave Package,  Next: Using Octave Mode,  Prev: Emacs,  Up: Emacs
  451. Installing the Emacs Octave Package
  452. ===================================
  453.    The Emacs package `octave' consists of `octave-mod.el',
  454. `octave-inf.el', and `octave-hlp.el'.  These files, or better yet their
  455. byte-compiled versions, should be somewhere in your Emacs load-path.
  456.    If you have GNU Emacs with a version number at least as high as
  457. 19.35, you are all set up, because the package is respectively will be
  458. part of GNU Emacs as of version 19.35.
  459.    Otherwise, copy the three files from the `emacs' subdirectory of the
  460. Octave distribution to a place where Emacs can find them (this depends
  461. on how your Emacs was installed).  Byte-compile them for speed if you
  462. want.
  463. File: octave,  Node: Using Octave Mode,  Next: Running Octave From Within Emacs,  Prev: Installing the Emacs Octave Package,  Up: Emacs
  464. Using Octave Mode
  465. =================
  466.    If you are lucky, your sysadmins have already arranged everything so
  467. that Emacs automatically goes into Octave mode whenever you visit an
  468. Octave code file as characterized by its extension `.m'.  If not,
  469. proceed as follows.
  470.   1. To begin using Octave mode for all `.m' files you visit, add the
  471.      following lines to a file loaded by Emacs at startup time,
  472.      typically your `~/.emacs' file:
  473.           (autoload 'octave-mode "octave-mod" nil t)
  474.           (setq auto-mode-alist
  475.                 (cons '("\\.m$" . octave-mode) auto-mode-alist))
  476.   2. Finally, to turn on the abbrevs, auto-fill and font-lock features
  477.      automatically, also add the following lines to one of the Emacs
  478.      startup files:
  479.           (add-hook 'octave-mode-hook
  480.                     (lambda ()
  481.                       (abbrev-mode 1)
  482.                       (auto-fill-mode 1)
  483.                       (if (eq window-system 'x)
  484.                           (font-lock-mode 1))))
  485.      See the Emacs manual for more information about how to customize
  486.      Font-lock mode.
  487.    In Octave mode, the following special Emacs commands can be used in
  488. addition to the standard Emacs commands.
  489. `C-h m'
  490.      Describe the features of Octave mode.
  491. `LFD'
  492.      Reindent the current Octave line, insert a newline and indent the
  493.      new line (`octave-reindent-then-newline-and-indent').  An abbrev
  494.      before point is expanded if `abbrev-mode' is non-`nil'.
  495. `TAB'
  496.      Indents current Octave line based on its contents and on previous
  497.      lines (`indent-according-to-mode').
  498.      Insert an "electric" semicolon (`octave-electric-semi').  If
  499.      `octave-auto-newline' is non-`nil', typing a `;' automatically
  500.      reindents the current line, inserts a newline and indents the new
  501.      line.
  502.      Start entering an abbreviation (`octave-abbrev-start').  If Abbrev
  503.      mode is turned on, typing ``C-h' or ``?' lists all abbrevs.  Any
  504.      other key combination is executed normally.  Note that all Octave
  505.      abbrevs start with a grave accent.
  506. `M-LFD'
  507.      Break line at point and insert continuation marker and alignment
  508.      (`octave-split-line').
  509. `M-TAB'
  510.      Perform completion on Octave symbol preceding point, comparing that
  511.      symbol against Octave's reserved words and builtin variables
  512.      (`octave-complete-symbol').
  513. `M-C-a'
  514.      Move backward to the beginning of a function
  515.      (`octave-beginning-of-defun').  With prefix argument N, do it that
  516.      many times if N is positive;  otherwise, move forward to the N-th
  517.      following beginning of a function.
  518. `M-C-e'
  519.      Move forward to the end of a function (`octave-end-of-defun').
  520.      With prefix argument N, do it that many times if N is positive;
  521.      otherwise, move back to the N-th preceding end of a function.
  522. `M-C-h'
  523.      Puts point at beginning and mark at the end of the current Octave
  524.      function, i.e., the one containing point or following point
  525.      (`octave-mark-defun').
  526. `M-C-q'
  527.      Properly indents the Octave function which contains point
  528.      (`octave-indent-defun').
  529. `M-;'
  530.      If there is no comment already on this line, create a code-level
  531.      comment (started by two comment characters) if the line is empty,
  532.      or an in-line comment (started by one comment character) otherwise
  533.      (`octave-indent-for-comment').  Point is left after the start of
  534.      the comment which is properly aligned.
  535. `C-c ;'
  536.      Puts the comment character `#' (more precisely, the string value of
  537.      `octave-comment-start') at the beginning of every line in the
  538.      region (`octave-comment-region').  With just `C-u' prefix
  539.      argument, uncomment each line in the region.  A numeric prefix
  540.      argument N means use N comment characters.
  541. `C-c :'
  542.      Uncomments every line in the region (`octave-uncomment-region').
  543. `C-c C-p'
  544.      Move one line of Octave code backward, skipping empty and comment
  545.      lines (`octave-previous-code-line').  With numeric prefix argument
  546.      N, move that many code lines backward (forward if N is negative).
  547. `C-c C-n'
  548.      Move one line of Octave code forward, skipping empty and comment
  549.      lines (`octave-next-code-line').  With numeric prefix argument N,
  550.      move that many code lines forward (backward if N is negative).
  551. `C-c C-a'
  552.      Move to the `real' beginning of the current line
  553.      (`octave-beginning-of-line').  If point is in an empty or comment
  554.      line, simply go to its beginning;  otherwise, move backwards to the
  555.      beginning of the first code line which is not inside a continuation
  556.      statement,  i.e., which does not follow a code line ending in `...'
  557.      or `\', or is inside an open parenthesis list.
  558. `C-c C-e'
  559.      Move to the `real' end of the current line (`octave-end-of-line').
  560.      If point is in a code line, move forward to the end of the first
  561.      Octave code line which does not end in `...' or `\' or is inside an
  562.      open parenthesis list.  Otherwise, simply go to the end of the
  563.      current line.
  564. `C-c M-C-n'
  565.      Move forward across one balanced begin-end block of Octave code
  566.      (`octave-forward-block').  With numeric prefix argument N, move
  567.      forward across N such blocks (backward if N is negative).
  568. `C-c M-C-p'
  569.      Move back across one balanced begin-end block of Octave code
  570.      (`octave-backward-block').  With numeric prefix argument N, move
  571.      backward across N such blocks (forward if N is negative).
  572. `C-c M-C-d'
  573.      Move forward down one begin-end block level of Octave code
  574.      (`octave-down-block').  With numeric prefix argument, do it that
  575.      many times;  a negative argument means move backward, but still go
  576.      down one level.
  577. `C-c M-C-u'
  578.      Move backward out of one begin-end block level of Octave code
  579.      (`octave-backward-up-block').  With numeric prefix argument, do it
  580.      that many times; a negative argument means move forward, but still
  581.      to a less deep spot.
  582. `C-c M-C-h'
  583.      Put point at the beginning of this block, mark at the end
  584.      (`octave-mark-block').  The block marked is the one that contains
  585.      point or follows point.
  586. `C-c ]'
  587.      Close the current block on a separate line (`octave-close-block').
  588.      An error is signaled if no block to close is found.
  589. `C-c f'
  590.      Insert a function skeleton, prompting for the function's name,
  591.      arguments and return values which have to be entered without parens
  592.      (`octave-insert-defun').
  593. `C-c C-h'
  594.      Search the function, operator and variable indices of all info
  595.      files with documentation for Octave for entries (`octave-help').
  596.      If used interactively, the entry is prompted for with completion.
  597.      If multiple matches are found, one can cycle through them using
  598.      the standard `,' (`Info-index-next') command of the Info reader.
  599.      The variable `octave-help-files' is a list of files to search
  600.      through and defaults to `'("octave")'.  If there is also an Octave
  601.      Local Guide with corresponding info file, say, `octave-LG', you can
  602.      have `octave-help' search both files by
  603.           (setq octave-help-files '("octave" "octave-LG"))
  604.      in one of your Emacs startup files.
  605.    A common problem is that the RET key does *not* indent the line to
  606. where the new text should go after inserting the newline.  This is
  607. because the standard Emacs convention is that RET (aka `C-m') just adds
  608. a newline, whereas LFD (aka `C-j') adds a newline and indents it.  This
  609. is particularly inconvenient for users with keyboards which do not have
  610. a special LFD key at all;  in such cases, it is typically more
  611. convenient to use RET as the LFD key (rather than typing `C-j').
  612.    You can make RET do this by adding
  613.      (define-key octave-mode-map "\C-m"
  614.        'octave-reindent-then-newline-and-indent)
  615. to one of your Emacs startup files.  Another, more generally applicable
  616. solution is
  617.      (defun RET-behaves-as-LFD ()
  618.        (let ((x (key-binding "\C-j")))
  619.          (local-set-key "\C-m" x)))
  620.      (add-hook 'octave-mode-hook 'RET-behaves-as-LFD)
  621. (this works for all modes by adding to the startup hooks, without having
  622. to know the particular binding of RET in that mode!).  Similar
  623. considerations apply for using `M-RET' as `M-LFD'.  As Barry A. Warsaw
  624. <bwarsaw@cnri.reston.va.us> says in the documentation for his
  625. `cc-mode', "This is a very common question. `:-)' If you want this to
  626. be the default behavior, don't lobby me, lobby RMS!"
  627.    The following variables can be used to customize Octave mode.
  628. `octave-auto-newline'
  629.      Non-`nil' means auto-insert a newline and indent after semicolons
  630.      are typed.  The default value is `nil'.
  631. `octave-blink-matching-block'
  632.      Non-`nil' means show matching begin of block when inserting a
  633.      space, newline or `;' after an else or end keyword.  Default is
  634.      `t'.  This is an extremely useful feature for automatically
  635.      verifying that the keywords match--if they don't, an error message
  636.      is displayed.
  637. `octave-block-offset'
  638.      Extra indentation applied to statements in block structures.
  639.      Default is 2.
  640. `octave-continuation-offset'
  641.      Extra indentation applied to Octave continuation lines.  Default
  642.      is 4.
  643. `octave-continuation-string'
  644.      String used for Octave continuation lines.  Normally `\'.
  645. `octave-mode-startup-message'
  646.      If `t' (default), a startup message is displayed when Octave mode
  647.      is called.
  648.    If Font Lock mode is enabled, Octave mode will display
  649.    * strings in `font-lock-string-face'
  650.    * comments in `font-lock-comment-face'
  651.    * the Octave reserved words (such as all block keywords) and the text
  652.      functions (such as `cd' or `who') which are also reserved using
  653.      `font-lock-keyword-face'
  654.    * the builtin operators (`&&', `<>', ...) using
  655.      `font-lock-reference-face'
  656.    * the builtin variables (such as `prefer_column_vectors', `NaN' or
  657.      `LOADPATH') in `font-lock-variable-name-face'
  658.    * and the function names in function declarations in
  659.      `font-lock-function-name-face'.
  660.    There is also rudimentary support for Imenu (currently, function
  661. names can be indexed).
  662.    Customization of Octave mode can be performed by modification of the
  663. variable `octave-mode-hook'.  It the value of this variable is
  664. non-`nil', turning on Octave mode calls its value.
  665.    If you discover a problem with Octave mode, you can conveniently
  666. send a bug report using `C-c C-b' (`octave-submit-bug-report').  This
  667. automatically sets up a mail buffer with version information already
  668. added.  You just need to add a description of the problem, including a
  669. reproducible test case and send the message.
  670. File: octave,  Node: Running Octave From Within Emacs,  Next: Using the Emacs Info Reader for Octave,  Prev: Using Octave Mode,  Up: Emacs
  671. Running Octave From Within Emacs
  672. ================================
  673.    The package `octave' provides commands for running an inferior
  674. Octave process in a special Emacs buffer.  Use
  675.      M-x run-octave
  676. to directly start an inferior Octave process.  If Emacs does not know
  677. about this command, add the line
  678.      (autoload 'run-octave "octave-inf" nil t)
  679. to your `.emacs' file.
  680.    This will start Octave in a special buffer the name of which is
  681. specified by the variable `inferior-octave-buffer' and defaults to
  682. `"*Inferior Octave*"'.  From within this buffer, you can interact with
  683. the inferior Octave process `as usual', i.e., by entering Octave
  684. commands at the prompt.  The buffer is in Inferior Octave mode, which
  685. is derived from the standard Comint mode, a major mode for interacting
  686. with an inferior interpreter.  See the documentation for `comint-mode'
  687. for more details, and use `C-h b' to find out about available special
  688. keybindings.
  689.    You can also communicate with an inferior Octave process from within
  690. files with Octave code (i.e., buffers in Octave mode), using the
  691. following commands.
  692. `C-c i l'
  693.      Send the current line to the inferior Octave process
  694.      (`octave-send-line').  With positive prefix argument N, send that
  695.      many lines.  If `octave-send-line-auto-forward' is non-`nil', go
  696.      to the next unsent code line.
  697. `C-c i b'
  698.      Send the current block to the inferior Octave process
  699.      (`octave-send-block').
  700. `C-c i f'
  701.      Send the current function to the inferior Octave process
  702.      (`octave-send-defun').
  703. `C-c i r'
  704.      Send the region to the inferior Octave process
  705.      (`octave-send-region').
  706. `C-c i s'
  707.      Make sure that `inferior-octave-buffer' is displayed
  708.      (`octave-show-process-buffer').
  709. `C-c i h'
  710.      Delete all windows that display the inferior Octave buffer
  711.      (`octave-hide-process-buffer').
  712. `C-c i k'
  713.      Kill the inferior Octave process and its buffer
  714.      (`octave-kill-process').
  715.    The effect of the commands which send code to the Octave process can
  716. be customized by the following variables.
  717. `octave-send-echo-input'
  718.      Non-`nil' means echo input sent to the inferior Octave process.
  719.      Default is `t'.
  720. `octave-send-show-buffer'
  721.      Non-`nil' means display the buffer running the Octave process after
  722.      sending a command (but without selecting it).  Default is `t'.
  723.    If you send code and there is no inferior Octave process yet, it
  724. will be started automatically.
  725.    The startup of the inferior Octave process is highly customizable.
  726. The variable `inferior-octave-startup-args' can be used for specifying
  727. command lines arguments to be passed to Octave on startup as a list of
  728. strings.  For example, to suppress the startup message and use
  729. `traditional' mode, set this to `'("-q" "--traditional")'.  You can
  730. also specify a startup file of Octave commands to be loaded on startup;
  731. note that these commands will not produce any visible output in the
  732. process buffer.  Which file to use is controlled by the variable
  733. `inferior-octave-startup-file'.  If this is `nil', the file
  734. `~/.emacs-octave' is used if it exists.
  735.    And finally, `inferior-octave-mode-hook' is run after starting the
  736. process and putting its buffer into Inferior Octave mode.  Hence, if you
  737. like the up and down arrow keys to behave in the interaction buffer as
  738. in the shell, and you want this buffer to use nice colors, add
  739.      (add-hook 'inferior-octave-mode-hook
  740.                (lambda ()
  741.                  (turn-on-font-lock)
  742.                  (define-key inferior-octave-mode-map [up]
  743.                    'comint-previous-input)
  744.                  (define-key inferior-octave-mode-map [down]
  745.                    'comint-next-input)))
  746. to your `.emacs' file.  You could also swap the roles of `C-a'
  747. (`beginning-of-line') and `C-c C-a' (`comint-bol') using this hook.
  748.      *Note:* If you set your Octave prompts to something different from
  749.      the defaults, make sure that `inferior-octave-prompt' matches them.
  750.      Otherwise, *nothing* will work, because Emacs will have no idea
  751.      when Octave is waiting for input, or done sending output.
  752. File: octave,  Node: Using the Emacs Info Reader for Octave,  Prev: Running Octave From Within Emacs,  Up: Emacs
  753. Using the Emacs Info Reader for Octave
  754. ======================================
  755.    You can also have Octave's `help -i' command invoke the Emacs Info
  756. reader.  To do this, you'll need `gnuserv', which can be retrieved from
  757. any GNU Emacs Lisp Code Directory archive, e.g.
  758. (ftp://ftp.cis.ohio-state.edu/pub/gnu/emacs/elisp-archive), in the
  759. `packages' subdirectory.  The alpha version of an enhanced version of
  760. gnuserv is available at
  761. (ftp://ftp.wellfleet.com/netman/psmith/emacs/gnuserv-2.1alpha.tar.gz).
  762.    If `gnuserv' is installed, add the lines
  763.      (autoload 'octave-help "octave-hlp" nil t)
  764.      (require 'gnuserv)
  765.      (gnuserv-start)
  766. to your `.emacs' file.
  767.    You can use either `plain' Emacs Info or the function `octave-help'
  768. as your Octave info reader (for `help -i').  In the former case, set
  769. the Octave variable `INFO_PROGRAM' to `"info-emacs-info"'.  The latter
  770. is perhaps more attractive because it allows to look up keys in the
  771. indices of *several* info files related to Octave (provided that the
  772. Emacs variable `octave-help-files' is set correctly).  In this case,
  773. set `INFO_PROGRAM' to `"info-emacs-octave-help"'.
  774.    If you use Octave from within Emacs, these settings are best done in
  775. the startup file `~/.emacs-octave' (or the file pointed to by the Emacs
  776. variable `inferior-octave-startup-file').
  777. File: octave,  Node: Grammar,  Next: Copying,  Prev: Emacs,  Up: Top
  778. Grammar
  779. *******
  780.    Someday I hope to expand this to include a semi-formal description of
  781. Octave's language.
  782. * Menu:
  783. * Keywords::
  784. File: octave,  Node: Keywords,  Prev: Grammar,  Up: Grammar
  785. Keywords
  786. ========
  787.    The following identifiers are keywords, and may not be used as
  788. variable or function names:
  789.      all_va_args             endwhile
  790.      break                   for
  791.      case                    function
  792.      catch                   global
  793.      continue                gplot
  794.      else                    gsplot
  795.      elseif                  if
  796.      end                     otherwise
  797.      end_try_catch           return
  798.      end_unwind_protect      switch
  799.      endfor                  try
  800.      endfunction             unwind_protect
  801.      endif                   unwind_protect_cleanup
  802.      endswitch               while
  803.    The following command-like functions are also speical.  They may be
  804. used as simple variable names, but not as formal parameters for
  805. functions, or as the names of structure variables.  Failed assignments
  806. leave them undefined (you can recover the orginal definition as a
  807. function using clear).
  808.      casesen       echo          load          show
  809.      cd            edit_history  ls            type
  810.      chdir         format        more          which
  811.      clear         help          run_history   who
  812.      diary         history       save          whos
  813.      dir           hold          set
  814.